package pack;

class Caisse {
   int id;
   boolean cmdEnCours;
   boolean cmdPrete;
   Caisse(int id) {
     this.id = id;
     cmdEnCours = false;
     cmdPrete= false;
   }
   public synchronized void doitPreparerCommande() {
      while ( !cmdEnCours ) {
        try {
          wait();
        }catch(InterruptedException e) {
          e.printStackTrace();
        }
      }
   }
   public synchronized void commandeBigMacFrites() {
      cmdEnCours=true;
      notifyAll();
   }
   public synchronized void commandeEstPrete() {
      cmdEnCours=false;
      cmdPrete = true;
      notifyAll();
   }
   public synchronized void prendCommande() {
      while ( !cmdPrete ) {
        try {
          wait();
        }catch(InterruptedException e) {
          e.printStackTrace();
        }
      }
      cmdPrete = false;
   }

}